<%@ include file="/en/jsp/static.jsp" %>
<%@ page import="java.util.*,linuxbox.calendar.logic.*,linuxbox.BoxStatic" %>
<%@ taglib uri="/linuxbox/common.tld" prefix="common" %>

<%
  BoxCalendar BoxCalHome = BoxCalendar.getInstance();

  Calendar currentDate = (Calendar)session.getAttribute("currentDate");
  if ( currentDate == null)
  {
    currentDate = Calendar.getInstance(sec.getTimeZone());
    session.setAttribute("currentDate",currentDate);
  }
  int workStartHour = sec.getConfigInt("calendar", "General", "Working Hour Start");

  Calendar tmpDay = (Calendar)currentDate.clone();
  tmpDay.set(Calendar.HOUR_OF_DAY,0);
  tmpDay.set(Calendar.MINUTE,0);
  tmpDay.set(Calendar.SECOND,0);
%>

<table width="100%" border=1 cellpadding=2 cellspacing=0 bgColor=#dddddd>
  <tr bgcolor="white">
    <td>
      <table width="100%" border=0 cellpadding=0 cellspacing=0>
        <tr>
          <td>
            <p align="center"><b><font color=#d05000>Today's Calendar</font></b></p>
          </td>
          <td nowrap align=right>
            <a href="<%=BoxStatic.servletDir%>BoxCalendarAction?SubmitEdit=edit&t=<%=(tmpDay.getTime().getTime()+1000*60*60*workStartHour)%>">Add</a>
              &nbsp;|&nbsp;
            <a href="<%=BoxStatic.jspDir%>calendar/BoxCalendar.jsp">More...</a>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <table width="100%" cellpadding=0 cellspacing=0 border=0>

<%
  int count = 0;
  Iterator it = BoxCalHome.getAllDayEntries(curID, tmpDay, curID);
  if (it !=null && it.hasNext())
  {
    while (it.hasNext())
    {
      BoxCalendarEntry bean = (BoxCalendarEntry) it.next();
      if ( bean != null )
      {
        count++;
%>
        <tr <% if ((count % 2) == 0) out.print("bgcolor=#f0f0f0"); %>>
          <td valign="top" align="left">
            <font size="-1">
              <a href="<%=BoxStatic.servletDir%>BoxCalendarAction?SubmitEdit=edit&id=<%=bean.getID()%>"
                  >&nbsp;&nbsp;&nbsp;All day&nbsp;&nbsp;&nbsp;<%=bean.getSubject()%>
              </a>
              <a href="<%=BoxStatic.servletDir%>BoxCalendarAction?SubmitDelete=del&id=<%=bean.getID()%>">
                <img SRC="<%=BoxStatic.imageDir%>cal_del.gif" WIDTH="12" HEIGHT="12" BORDER="0" ALIGN="right"
                Onclick='return confirmDel("<%=bean.getSubject()+ " " + BoxCalHome.getTimeRangeString(bean, currentDate.getTimeZone())%>")'
                ALT="Delete">
              </a>
            </font>
          </td>
        </tr>
<%
      }
    }
  }
  it = BoxCalHome.getEntries(curID, tmpDay,curID);
  if (it !=null && it.hasNext())
  {
    while (it.hasNext())
    {
      BoxCalendarEntry bean = (BoxCalendarEntry) it.next();
      if ( bean != null )
      {
        count++;
%>
        <tr <% if ((count % 2) == 0) out.print("bgcolor=#f0f0f0"); %>>
          <td valign="top" align="left">
            <font size="-1">
              <a href="<%=BoxStatic.servletDir%>BoxCalendarAction?SubmitEdit=edit&id=<%=bean.getID()%>"
                  >&nbsp;&nbsp;&nbsp;<%=BoxCalHome.getTimeRangeString(bean, currentDate.getTimeZone())%>&nbsp;&nbsp;&nbsp;<%=bean.getSubject()%>
              </a>
              <a href="<%=BoxStatic.servletDir%>BoxCalendarAction?SubmitDelete=del&id=<%=bean.getID()%>">
                <img SRC="<%=BoxStatic.imageDir%>cal_del.gif" WIDTH="12" HEIGHT="12" BORDER="0" ALIGN="right"
                Onclick='return confirmDel("<%=bean.getSubject()+ " " + BoxCalHome.getTimeRangeString(bean, currentDate.getTimeZone())%>")'
                ALT="Delete">
              </a>
            </font>
          </td>
        </tr>
<%
      }
    }
  }

  if (count == 0)
  {
     out.print("<tr> <td bgcolor=\"#eeeeee\"><br> </td> </tr>");
  }
%>
      </table>
    </td>
  </tr>
</table>
